package internal

import (
	"base"
	"leaf/gate"
	"login_server/chanrpc"
	. "login_server/internal"
	"login_server/logic"
)

type Module struct {
	*gate.Client
}

func (module *Module) OnPrepare() {
	client := new(gate.Client)
	client.AutoReconnect = AutoReconnect
	client.ConnectInterval = ConnectInterval
	client.PendingWriteNum = PendingWriteNum
	client.MaxMsgLen = MaxMsgLen
	client.Processor = base.Processor

	client.TCPAddr = Config.CenterServerAddr
	client.LenMsgLen = LenMsgLen
	client.LittleEndian = base.LittleEndian
	client.TcpConnNum = 1
	client.NewTcpAgent = chanrpc.NewCenterAgent
	client.CloseTcpAgent = chanrpc.CloseCenterAgent

	module.Client = client
}

func (module *Module) OnInit() {
	module.Client.AgentChanRPC = logic.ChanRpc
}
